/**
 * Project:   dtu.fmes.googleloon
 * File:      KillRandomBalloon.java
 * License: 
 *            This file is licensed under GNU General Public License version 3
 *            http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Copyright:	Nicolai Sonne [ NicolaiSonne@hotmail.com.com ]
 * Date:      Dec 11, 2013
 */

package dtu.fmes.loon.model;

/**
 * Class used to define time and optionally area of which to kill random balloons.
 * 
 * @author Nicolai Sonne
 */
public class KillRandomBalloon {

	// Restrict by area
	private Double xStart = null;

	private Double xStop = null;

	private Double yStart = null;

	private Double yStop = null;

	// Time at which to be executed
	private Long time = null;

	private boolean executed = false;

	/**
	 * Kill balloon with area constraints
	 * 
	 * @param xStart
	 * @param xStop
	 * @param yStart
	 * @param yStop
	 * @param time
	 */
	public KillRandomBalloon(Double xStart, Double xStop, Double yStart, Double yStop, Long time) {
		this.xStart = xStart;
		this.xStop = xStop;
		this.yStart = yStart;
		this.yStop = yStop;
		this.time = time;
	}

	/**
	 * Kill balloon without area constraints
	 * 
	 * @param time
	 */
	public KillRandomBalloon(Long time) {
		super();
		this.time = time;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		KillRandomBalloon other = (KillRandomBalloon) obj;
		if (executed != other.executed) {
			return false;
		}
		if (time == null) {
			if (other.time != null) {
				return false;
			}
		} else if (!time.equals(other.time)) {
			return false;
		}
		if (xStart == null) {
			if (other.xStart != null) {
				return false;
			}
		} else if (!xStart.equals(other.xStart)) {
			return false;
		}
		if (xStop == null) {
			if (other.xStop != null) {
				return false;
			}
		} else if (!xStop.equals(other.xStop)) {
			return false;
		}
		if (yStart == null) {
			if (other.yStart != null) {
				return false;
			}
		} else if (!yStart.equals(other.yStart)) {
			return false;
		}
		if (yStop == null) {
			if (other.yStop != null) {
				return false;
			}
		} else if (!yStop.equals(other.yStop)) {
			return false;
		}
		return true;
	}

	public Long getTime() {
		return time;
	}

	public Double getxStart() {
		return xStart;
	}

	public Double getxStop() {
		return xStop;
	}

	public Double getyStart() {
		return yStart;
	}

	public Double getyStop() {
		return yStop;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (executed ? 1231 : 1237);
		result = prime * result + (time == null ? 0 : time.hashCode());
		result = prime * result + (xStart == null ? 0 : xStart.hashCode());
		result = prime * result + (xStop == null ? 0 : xStop.hashCode());
		result = prime * result + (yStart == null ? 0 : yStart.hashCode());
		result = prime * result + (yStop == null ? 0 : yStop.hashCode());
		return result;
	}

	public boolean isExecuted() {
		return executed;
	}

	public void setExecuted(boolean executed) {
		this.executed = executed;
	}

	public void setTime(Long time) {
		this.time = time;
	}

	public void setxStart(Double xStart) {
		this.xStart = xStart;
	}

	public void setxStop(Double xStop) {
		this.xStop = xStop;
	}

	public void setyStart(Double yStart) {
		this.yStart = yStart;
	}

	public void setyStop(Double yStop) {
		this.yStop = yStop;
	}

	@Override
	public String toString() {
		return "KillRandomBalloon [xStart=" + xStart + ", xStop=" + xStop + ", yStart=" + yStart + ", yStop=" + yStop + ", time=" + time
		        + ", executed=" + executed + "]";
	}

}
